/*
 * Brian M. Luger
 * Main Welcome Panel
 * Date: 12/3/2011
 */
package gui.welcome;

import gui.CAFrame;

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;

import caobject.Conference;

/**
 * Main Welcome Panel
 * 
 * @author Brian M. Luger
 * @version 12/3/2011
 */
@SuppressWarnings("serial")
public class WelcomeMainPanel extends JPanel{
	
	/**
	 * Background Image Path
	 */
	private static final String BACKGROUND = 
		"src/images/AbstractBackground.png";
	/**
	 * Parent Frame
	 */
	private final CAFrame my_parent;
	
	/**
	 * Welcome Panel - North Panel
	 */
	private final WelcomeNorthPanel my_northPanel;
	
	/**
	 * Welcome Panel - Center Panel
	 */
	private final WelcomeCenterPanel my_centerPanel;
	
	/**
	 * Welcome Panel - South Panel
	 */
	private final WelcomeSouthPanel my_southPanel;
	
	/**
	 * WelcomeMainPanel Constructor
	 * 
	 * @param parentFrame Parent Frame
	 */
	public WelcomeMainPanel(final CAFrame parentFrame,
			final ArrayList<Conference> the_confData) {
		my_parent = parentFrame;
		
		my_northPanel = 
			new WelcomeNorthPanel(my_parent);
		
		my_centerPanel = 
			new WelcomeCenterPanel(my_parent);
		
		my_southPanel =
			new WelcomeSouthPanel(my_parent, 
					WelcomeMainPanel.this, 
					the_confData);
		
		init();
	}
	
	/**
	 * Panel Initialization
	 */
	private void init() {
		setLayout(new BorderLayout());
		
		// North Panel ------------------------------------
		add(my_northPanel, BorderLayout.NORTH);
		// ------------------------------------------------
		
		// Center Panel -----------------------------------
		add(my_centerPanel, BorderLayout.CENTER);
		// ------------------------------------------------
		
		// South Panel ------------------------------------
		add(my_southPanel, BorderLayout.SOUTH);
		// ------------------------------------------------
		
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public void paintComponent(final Graphics the_graphics) {
		super.paintChildren(the_graphics);
		final Graphics2D g2d = (Graphics2D) the_graphics;
		
		final Image img = 
			new ImageIcon(BACKGROUND).getImage();
		g2d.drawImage(img, 0, 0, null);
	}
}
